package com.mybook.controller;

import com.mybook.entity.Book;
import com.mybook.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("book")  //book表数据相关请求主入口
@CrossOrigin
public class BookController {

    @Autowired
    private BookService bookService;

    @RequestMapping("getBooksByCid")
    @ResponseBody   //返回数据内容本身（通常返回json格式数据）
    public List<Book> getBooksByCidData(Integer cid){
        return bookService.getBooksByCid(cid);
    }
}
